package com.yellowpage.wf.data;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.collections.map.LinkedMap;

public class WorkflowDataUtils implements java.io.Serializable {
	public static final String ENTITY_STATUS_ON = "on";
	public static final String ENTITY_STATUS_OFF = "off";
	public static final String WORK_STATUS_END = "end";
	public static final String WORK_STATUS_ON = "on";
	public static final String NODE_TYPE_START = "start";
	public static final String NODE_TYPE_END = "end";
	public static final String NODE_TYPE_DEAL = "deal";
	public static final String NODE_TYPE_AUTO = "auto";
	public static final String START_POINT_DISPLAYNAME = "开始节点";
	public static final String END_POINT_DISPLAYNAME = "结束节点";
	public static final String DEFAULT_OWNER_NAME = "默认操作员";
	public static final Long DEFAULT_OWNER = new Long(-10000);

	public static Map takeWorkflowStatusMap() {
		return getEntityStatusMap();
	}

	public static Map takeWorkflowNodeStatusMap() {
		return getEntityStatusMap();
	}

	public static Map takeWorkflowPathStatusMap() {
		return getEntityStatusMap();
	}

	private static Map getEntityStatusMap() {
		Map statusMap = new LinkedMap();
		statusMap.put(ENTITY_STATUS_ON, "启用");
		statusMap.put(ENTITY_STATUS_OFF, "停用");
		return statusMap;
	}

	public static Map takeWorkflowInstanceStatusMap() {
		return getWorkStatusMap();
	}

	public static Map takeWorkflowNodeAllTypeMap(){
		Map typeMap= getTypeMap();
		typeMap.put(NODE_TYPE_START, "开始节点");
		typeMap.put(NODE_TYPE_END, "结束节点");
		return typeMap;
	}
	public static Map takeWorkflowNodeWorkTypeMap(){
		return getTypeMap();
	}
	private static Map getWorkStatusMap() {
		Map statusMap = new LinkedMap();
		statusMap.put(WORK_STATUS_ON, "工作中");
		statusMap.put(WORK_STATUS_END, "结束");
		return statusMap;
	}

	private static Map getTypeMap(){
		Map typeMap = new LinkedMap();
		typeMap.put(NODE_TYPE_DEAL, "处理节点");
		typeMap.put(NODE_TYPE_AUTO, "自动节点(根据条件判断走哪条路 非人工操控路由)");
		return typeMap;
	}
	
	public static Map getWorkflowContextTypeMap(){
		Map typeMap = new LinkedMap();
		typeMap.put("PUBLIC", "公共参数(用户可修改)");		
		typeMap.put("WORKFLOW", "流程参数");
		return typeMap;
	}

	public static boolean checkHeadTailSpace(String value){
		Pattern patt = Pattern.compile("(^[\\s]+)|([\\s]+$)");
		Matcher mat = patt.matcher(value);
		return mat.find();

	}

}
